/**
 * Created by Administrator on 2016/3/25.
 */
$(function(){
    $(".gContainer img").mousedown(function(){
        $(this).attr("src","images/gWant1.png");
    });
    $(".gContainer img").mouseup(function(){
        $(this).attr("src","images/gWant.png");
    });


    $(".gwant").click(function(){
    	$.ajax({
            url: "hxclub/sys/heart.do",
            async: false,
            type : "post",
            dataType : "json",
            success:function(d){
            	if(d.success){
            		$(".register,.center").show();
                }
                else{
                	//alert("请先登录后再报名");
                    $(".register,.login").show();
                    $(".login .less").mousedown(function(){
                        $(".less img").attr("src","images/galert4.png");
                    });
                    $(".login .less").mouseup(function(){
                        $(".less img").attr("src","images/galert2.png");
                    });
                    $(".login .del").click(function(){
                        $(".login,.register").hide();
                    });
                    $(".login .sure").mousedown(function(){
                        $(".sure img").attr("src","images/galert3.png");
                    });
                    $(".login .sure").mouseup(function(){
                        $(".sure img").attr("src","images/galert1.png");
                        window.location.href = 'login.html?redirectUrl=gActivedetail.html';
                    });

            	}
            }
        });
    })

    $(".center .less").mousedown(function(){
        $(".less img").attr("src","images/galert4.png");
    });
    $(".center .less").mouseup(function(){
        $(".less img").attr("src","images/galert2.png");
    });
    $(".center .del").click(function(){
        $(".center,.register").hide();
    });
    $(".center .sure").mousedown(function(){
        $(".sure img").attr("src","images/galert3.png");
    });
    $(".center .sure").mouseup(function(){
        $(".sure img").attr("src","images/galert1.png");
    });
    $(".center .sure").mouseup(function(){
        $.ajax({
            method:"POST",
            url:"hxclub/activity/join.do",
            data:{
                //uid:uid,
                aid:28
            },
            dataType:"JSON",
            success:function(data){
                if(data.statusCode==200){
                    //alert(data.data);
                    $(".timeout p").html(data.data);
                    $(".timeout").show();
                    $(".timeout .sure").mousedown(function(){
                        $(".sure img").attr("src","images/galert3.png");
                    });
                    $(".timeout .sure").mouseup(function(){
                        $(".sure img").attr("src","images/galert1.png");
                        $(".timeout").hide();
                    });
                }else{
                    //alert(data.data);
                    $(".timeout p").html(data.data);

                    $(".timeout").show();
                    $(".timeout .sure").mousedown(function(){
                        $(".sure img").attr("src","images/galert3.png");
                    });
                    $(".timeout .sure").mouseup(function(){
                        $(".sure img").attr("src","images/galert1.png");
                        $(".timeout").hide();
                    });
                }
            }

        })
    })
});